Skip to content

feat(openrouter): add OpenRouter plugin with 13 operations - #635

Open
Mayank-saraswal wants to merge 8 commits into
corsairdev:mainfrom
Mayank-saraswal:feat/openrouter-plugin
Open

feat(openrouter): add OpenRouter plugin with 13 operations#635
Mayank-saraswal wants to merge 8 commits into
corsairdev:mainfrom
Mayank-saraswal:feat/openrouter-plugin

Conversation

@Mayank-saraswal

@Mayank-saraswal Mayank-saraswal commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #634

Description

Adds a first-class OpenRouter plugin (@corsair-dev/openrouter) exposing the full 13-operation surface claimed on the OSS dashboard:

Chat & generation

  • chatCompletions.createPOST /chat/completions (OpenAI-compatible, with multi-provider routing, tool calling, structured output, reasoning)
  • messages.createPOST /messages (Anthropic Messages API format)
  • generations.getGET /generation?id={id}

Models

  • models.listGET /models (pricing, context length, supported parameters)
  • models.countGET /models/count
  • models.listEmbeddingsGET /embeddings/models (with offset/limit pagination)
  • models.listUserGET /models/user
  • modelEndpoints.listGET /models/{author}/{slug}/endpoints
  • providers.listGET /providers
  • zdr.listGET /endpoints/zdr

Account

  • credits.listGET /credits
  • key.getGET /key

All input/output types use Zod schemas, errors route through error-handlers.ts (incl. 429 + Retry-After), and the footprint is exactly the plugin package + the registration edit in packages/corsair/core/constants.ts + pnpm-lock.yaml.

Verified live against the OpenRouter API (real key): every GET endpoint's response shape is validated in the live test suite; both chat-completion formats return the expected shapes. pnpm run validate:plugins passes for openrouter.

Checklist

  • I have run pnpm lint and all checks pass (openrouter files clean; repo-wide lint has pre-existing failures in unrelated packages)
  • I have run pnpm typecheck and there are no TypeScript errors
  • I have run pnpm build and all packages build successfully (openrouter builds clean via tsc --build --force && tsup)
  • I have run pnpm test and all tests pass (43/43 in @corsair-dev/openrouter, incl. live API tests)
  • I have added or updated tests where applicable
  • I have added or updated necessary documentation

Screenshots / Demos (if applicable)

Demo video showing the integration working end-to-end:

https://www.loom.com/share/5e7438d01bac4f76b6bcc351950b0f8b

Additional Notes

  • New endpoints were cross-checked against the current OpenRouter API reference and verified live (e.g. GET /embeddings/models is the actual embedding-models path, GET /models/{author}/{slug}/endpoints for model endpoints).

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@Mayank-saraswal is attempting to deploy a commit to the corsair Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ffe83bb7-8b00-4942-b78e-48ff604a649e

📥 Commits

Reviewing files that changed from the base of the PR and between e2394d0 and ccbc202.

📒 Files selected for processing (3)
  • packages/openrouter/api.test.ts
  • packages/openrouter/endpoints/types.ts
  • packages/openrouter/schema.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/openrouter/api.test.ts
  • packages/openrouter/endpoints/types.ts

📝 Walkthrough

Walkthrough

This PR adds the @corsair-dev/openrouter plugin. It defines typed OpenRouter schemas and endpoints, API-key authentication, error handling, tests, documentation, package configuration, and provider registration.

Changes

OpenRouter integration

Layer / File(s) Summary
Contracts and schemas
packages/openrouter/endpoints/types.ts, packages/openrouter/schema/*, packages/openrouter/schema.test.ts, packages/corsair/core/constants.ts
Adds Zod schemas, inferred endpoint types, schema registries, plugin metadata, schema tests, and the openrouter provider identifier.
API transport and endpoint operations
packages/openrouter/client.ts, packages/openrouter/endpoints/*
Adds Bearer-authenticated requests and typed handlers for chat completions, messages, models, embeddings, providers, generations, credits, keys, and ZDR endpoints.
Plugin wiring, authentication, and retries
packages/openrouter/index.ts, packages/openrouter/error-handlers.ts
Registers endpoints and schemas, resolves API keys from options or context, adds endpoint metadata, and configures error handling and retries.
Validation, documentation, and package setup
packages/openrouter/api.test.ts, packages/openrouter/README.md, packages/openrouter/package.json, packages/openrouter/jest.config.cjs, packages/openrouter/tsconfig.json, packages/openrouter/tsup.config.ts
Adds schema, mocked handler, error-handler, and live API tests, plus package documentation and build configuration.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: ⚪ Minimal · up to ccbc2

This PR adds the OpenRouter plugin and registration with reported validation, typecheck, build, and test checks passing; no actionable merge-blocking risk remains beyond normal review.

Sequence Diagram(s)

sequenceDiagram
  participant CorsairRequest
  participant OpenRouterPlugin
  participant OpenRouterClient
  participant OpenRouterAPI
  CorsairRequest->>OpenRouterPlugin: invokes a registered endpoint
  OpenRouterPlugin->>OpenRouterClient: passes endpoint path, API key, and request data
  OpenRouterClient->>OpenRouterAPI: sends authenticated HTTP request
  OpenRouterAPI-->>OpenRouterClient: returns JSON response or API error
  OpenRouterClient-->>OpenRouterPlugin: returns typed result or wrapped error
  OpenRouterPlugin-->>CorsairRequest: returns endpoint response
Loading

Possibly related PRs

  • corsairdev/corsair#344: Adds a typed provider plugin with similar contracts, schemas, error handling, tests, and packaging.
  • corsairdev/corsair#353: Uses a similar provider client, endpoint, schema, error-handler, test, and package structure.
  • corsairdev/corsair#552: Adds an analogous Corsair integration with client, endpoint, schema, error-handler, testing, packaging, and provider-registration changes.

Suggested labels: plugin, bot:round-1, bot:round-2, needs-maintainer

Suggested reviewers: devjain32

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR covers most requirements but does not implement the required Create Coinbase Charge operation from [#634]. Add the Create Coinbase Charge endpoint and its schemas, registration, error handling, and tests, or update the linked issue scope.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes remain within the OpenRouter plugin and its required provider registration, documentation, configuration, and tests.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding the OpenRouter plugin with 13 operations.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added core Changes in packages/corsair docs Docs / Mintlify / markdown changes labels Aug 9, 2026
@Mayank-saraswal
Mayank-saraswal marked this pull request as ready for review August 10, 2026 07:39
@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a first-class OpenRouter plugin and registers it with Corsair.

  • Exposes 13 typed operations covering generation, models, providers, embeddings, account metadata, and ZDR endpoints.
  • Adds API-key authentication, shared HTTP transport, retry/error handling, and best-effort entity persistence.
  • Adds Zod schemas, mocked and optional live API tests, package configuration, and usage documentation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/openrouter/index.ts Defines the plugin factory, API-key resolution, 13-operation endpoint tree, schemas, metadata, and error-handler registration.
packages/openrouter/endpoints/types.ts Defines the Zod input and output contracts for the complete OpenRouter operation surface.
packages/openrouter/client.ts Implements the shared bearer-authenticated OpenRouter HTTP transport while preserving structured Corsair HTTP errors.
packages/openrouter/error-handlers.ts Adds authentication, rate-limit, timeout, server, and default error policies with operation-aware transient retry behavior.
packages/openrouter/endpoints/persist.ts Adds non-fatal persistence helpers for models, providers, and generation metadata.
packages/openrouter/api.test.ts Exercises endpoint schemas, request mappings, error policies, persistence behavior, and optional live API response validation.
packages/corsair/core/constants.ts Registers the OpenRouter provider identifier and display name in Corsair's shared provider vocabulary.

Sequence Diagram

sequenceDiagram
  participant App as Host application
  participant Corsair as Corsair endpoint binding
  participant Plugin as OpenRouter plugin
  participant API as OpenRouter API
  participant DB as Corsair entity database

  App->>Corsair: Invoke openrouter.api operation
  Corsair->>Corsair: Check permission and resolve API key
  Corsair->>Plugin: Call typed endpoint with context
  Plugin->>API: Bearer-authenticated HTTP request
  API-->>Plugin: JSON response
  opt Models, providers, or generation metadata
    Plugin->>DB: Best-effort entity upsert
  end
  Plugin-->>Corsair: Return typed response
  Corsair-->>App: Validated operation result
Loading

Reviews (6): Last reviewed commit: "fix(openrouter): cache models, providers..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

🧹 Nitpick comments (6)
packages/openrouter/tsup.config.ts (1)

10-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider disabling minify for a library build.

minify: true with splitting: true produces unreadable chunk output. Consumers bundle this package themselves and lose readable stack traces. Most library packages leave minification to the consumer.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/openrouter/tsup.config.ts` around lines 10 - 11, Disable
minification in the tsup build configuration by changing the minify setting to
false or removing it, while preserving code splitting so consumers can bundle
readable library output themselves.
packages/openrouter/error-handlers.ts (1)

56-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider retrying 408 and simplifying the 5xx check.

Two points:

  • The header comment documents 408 as a request timeout, but no matcher handles it. A 408 falls to DEFAULT with maxRetries: 0. Timeouts are usually safe to retry for the read-only GET operations.
  • Line 60 checks error.status === 529 after error.status >= 500 && error.status < 600. The second check is unreachable.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/openrouter/error-handlers.ts` around lines 56 - 74, Update the
SERVER_ERROR matcher in error-handling configuration to include HTTP 408
alongside the existing retryable server statuses, preserving the current retry
strategy. Simplify the status condition by removing the redundant explicit 529
check, since the existing 5xx range already includes it.
packages/openrouter/schema.test.ts (1)

9-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the tautological assertion and the dangling comment.

Line 12 asserts Array.isArray(Object.keys(...)). Object.keys always returns an array, so this assertion can never fail. Assert the entity count or the expected entity names instead.

Lines 19-20 place a rule reference at file scope, but the endpoint tests live in packages/openrouter/api.test.ts. Move the note there or delete it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/openrouter/schema.test.ts` around lines 9 - 20, Update the test
around OpenrouterSchema.entities to replace the tautological Object.keys array
assertion with a meaningful entity-count or expected-entity-name assertion, and
remove the dangling file-scope PLUGIN_PR_RULES comment from schema.test.ts. If
the rule reference is still needed, move it to the endpoint tests in
api.test.ts.
packages/openrouter/jest.config.cjs (1)

5-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the template leftovers from the config.

Three settings do not apply to this package:

  • Lines 7-9 match tests/, plugins/, and setup/ directories. This package contains only api.test.ts and schema.test.ts at the root.
  • Line 16 excludes jest.config.ts, but the config file is jest.config.cjs. The pattern never matches.
  • Line 51 exempts uuid from transformIgnorePatterns. This package does not depend on uuid.

Also applies to: 51-51

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/openrouter/jest.config.cjs` around lines 5 - 18, Remove the unused
`testMatch` entries for `tests`, `plugins`, and `setup` from the Jest
configuration, leaving only the root `*.test.ts` pattern. Update
`collectCoverageFrom` to exclude the actual `jest.config.cjs` filename, and
remove the `uuid` exemption from `transformIgnorePatterns`.
packages/openrouter/tsconfig.json (1)

17-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Exclude the test files from the declaration build.

include covers ./**/*, so api.test.ts and schema.test.ts produce declaration files in dist. package.json ships the whole dist directory.

♻️ Proposed change
   "include": ["./**/*"],
-  "exclude": ["dist", "node_modules"],
+  "exclude": ["dist", "node_modules", "**/*.test.ts"],
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/openrouter/tsconfig.json` around lines 17 - 18, Update the
packages/openrouter TypeScript configuration to exclude api.test.ts and
schema.test.ts from declaration output while preserving the existing dist and
node_modules exclusions. Ensure the test files remain available to the test
tooling but are not emitted into the shipped dist directory.
packages/openrouter/endpoints/types.ts (1)

496-562: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Verify that the endpoint registries stay aligned with the plugin contract.

OpenRouterEndpointInputs, OpenRouterEndpointOutputs, OpenRouterEndpointInputSchemas, and OpenRouterEndpointOutputSchemas each list the same 14 keys, and they match OpenRouterEndpoints in packages/openrouter/index.ts (Lines 65-80). Four parallel maps must be edited together for every new operation. Nothing in the type system enforces that today, because each map is declared independently.

Consider deriving the type maps from the schema registries so that drift becomes a compile error.

♻️ Optional refactor
-export type OpenRouterEndpointInputs = {
-	chatCompletionsCreate: CreateChatCompletionInput;
-	// ...
-};
+export type OpenRouterEndpointInputs = {
+	[K in keyof typeof OpenRouterEndpointInputSchemas]: z.infer<
+		(typeof OpenRouterEndpointInputSchemas)[K]
+	>;
+};

The same pattern applies to OpenRouterEndpointOutputs. The registry constants must be declared before the type aliases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/openrouter/endpoints/types.ts` around lines 496 - 562, Refactor
OpenRouterEndpointInputs and OpenRouterEndpointOutputs to derive their key sets
and value types from OpenRouterEndpointInputSchemas and
OpenRouterEndpointOutputSchemas, so registry drift becomes a compile-time error.
Move both schema registry constants before the type aliases and use the existing
schema inference conventions to preserve each operation’s input and output
types. Keep the registries’ keys aligned with OpenRouterEndpoints.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/corsair/core/constants.ts`:
- Line 186: Update the openrouter entry in the provider display-name mapping to
use the official casing “OpenRouter”, ensuring formatProviderDisplayName returns
the corrected brand name.

In `@packages/openrouter/api.test.ts`:
- Around line 37-52: Update packages/openrouter/api.test.ts lines 37-52 so the
mocked makeOpenRouterRequest throws by default for unmocked calls, and import
the real client separately via jest.requireActual for the live suite; at lines
346-348 replace mockClear() with mockReset() to remove queued one-time values
before live tests. In packages/openrouter/README.md lines 59-61, retain the “no
API key” claim only once the mocked handler tests cannot reach the network.

In `@packages/openrouter/client.ts`:
- Around line 14-42: Update makeOpenRouterRequest to target the
LiteLLM-compatible llm.corsair.dev gateway instead of OPENROUTER_API_BASE, and
remove provider-specific OpenRouter bearer authentication using apiKey. Use the
Corsair-managed credential configuration required by the gateway while
preserving the existing request method, body, query, and generic response
handling.

In `@packages/openrouter/endpoints/credits.ts`:
- Around line 30-48: Remove the retired createCoinbaseCharge operation and all
related creditsCoinbaseCreate registrations, request/response schemas, types,
tests, and documentation. Ensure no Coinbase charge API path remains exposed,
and direct users to OpenRouter’s web-based credit purchase flow instead.

In `@packages/openrouter/endpoints/types.ts`:
- Around line 67-70: Remove the unsupported stream option from
CreateChatCompletionInputSchema, or reject stream: true in the corresponding
handler before invoking the non-streamed output validation. Ensure callers
cannot request streaming while CreateChatCompletionOutputSchema only supports
chat.completion responses with required usage.
- Around line 18-36: Update ChatMessageSchema’s assistant variant to accept an
optional tool_calls field using ToolCallSchema, and move ToolCallSchema’s
declaration before ChatMessageSchema so the reference resolves during module
evaluation. Preserve the existing optional content behavior and other
message-role variants.
- Around line 165-190: Widen the content block schema in
CreateAnthropicMessageOutputSchema to accept OpenRouter’s thinking,
redacted_thinking, and tool_use block types alongside text. Add explicit schemas
for those variants or a permissive fallback member while preserving validation
of existing text blocks.

In `@packages/openrouter/error-handlers.ts`:
- Around line 19-23: In the rate-limit matcher near the ApiError status check,
replace the broad message substring checks with matching anchored to the HTTP
status text or rely solely on ApiError.status, so unrelated values such as model
slugs, IDs, and durations do not match. In the matcher around the
invalid-message check, narrow the pattern to the intended status text and
prevent invalid_api_key from being classified as the invalid-request case.

In `@packages/openrouter/index.ts`:
- Around line 302-318: Clarify the intended precedence in the OpenRouter
keyBuilder: if tenant credentials must take priority, call
ctx.keys.get_api_key() before returning options.key and use the static key only
as fallback; otherwise preserve the current behavior and document in the README
that options.key overrides per-tenant keys.
- Around line 274-301: Update the OpenRouter model-call routing in the client
implementation to send requests through llm.corsair.dev instead of directly to
OpenRouter with ctx.key. Apply this to the model endpoints used by the
openrouter plugin while preserving the existing endpoint behavior and
authentication contract.

In `@packages/openrouter/package.json`:
- Line 19: Update the package.json test script to run Jest with Node’s
--experimental-vm-modules option, and change the corsair peer dependency range
from >=0.1.0 to ^0.1.0 to bound compatible versions.

In `@packages/openrouter/README.md`:
- Around line 63-77: Remove the “Live demo” section from the README until the
documented demo exists, including its environment-variable setup and pnpm
command; do not add a script or otherwise alter package.json.
- Around line 5-14: Update the “Auth setup” documentation to remove the
unsupported instruction to set OPENROUTER_API_KEY, and describe only the
credential sources handled by keyBuilder: options.key or Corsair credentials via
ctx.keys.get_api_key(). Keep the remaining authorization and missing-credentials
guidance unchanged.

---

Nitpick comments:
In `@packages/openrouter/endpoints/types.ts`:
- Around line 496-562: Refactor OpenRouterEndpointInputs and
OpenRouterEndpointOutputs to derive their key sets and value types from
OpenRouterEndpointInputSchemas and OpenRouterEndpointOutputSchemas, so registry
drift becomes a compile-time error. Move both schema registry constants before
the type aliases and use the existing schema inference conventions to preserve
each operation’s input and output types. Keep the registries’ keys aligned with
OpenRouterEndpoints.

In `@packages/openrouter/error-handlers.ts`:
- Around line 56-74: Update the SERVER_ERROR matcher in error-handling
configuration to include HTTP 408 alongside the existing retryable server
statuses, preserving the current retry strategy. Simplify the status condition
by removing the redundant explicit 529 check, since the existing 5xx range
already includes it.

In `@packages/openrouter/jest.config.cjs`:
- Around line 5-18: Remove the unused `testMatch` entries for `tests`,
`plugins`, and `setup` from the Jest configuration, leaving only the root
`*.test.ts` pattern. Update `collectCoverageFrom` to exclude the actual
`jest.config.cjs` filename, and remove the `uuid` exemption from
`transformIgnorePatterns`.

In `@packages/openrouter/schema.test.ts`:
- Around line 9-20: Update the test around OpenrouterSchema.entities to replace
the tautological Object.keys array assertion with a meaningful entity-count or
expected-entity-name assertion, and remove the dangling file-scope
PLUGIN_PR_RULES comment from schema.test.ts. If the rule reference is still
needed, move it to the endpoint tests in api.test.ts.

In `@packages/openrouter/tsconfig.json`:
- Around line 17-18: Update the packages/openrouter TypeScript configuration to
exclude api.test.ts and schema.test.ts from declaration output while preserving
the existing dist and node_modules exclusions. Ensure the test files remain
available to the test tooling but are not emitted into the shipped dist
directory.

In `@packages/openrouter/tsup.config.ts`:
- Around line 10-11: Disable minification in the tsup build configuration by
changing the minify setting to false or removing it, while preserving code
splitting so consumers can bundle readable library output themselves.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dcb25c43-06f1-4c96-96f0-adcfc45aab68

📥 Commits

Reviewing files that changed from the base of the PR and between 99ade55 and 974c387.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (24)
  • packages/corsair/core/constants.ts
  • packages/openrouter/README.md
  • packages/openrouter/api.test.ts
  • packages/openrouter/client.ts
  • packages/openrouter/endpoints/chat-completions.ts
  • packages/openrouter/endpoints/credits.ts
  • packages/openrouter/endpoints/embeddings.ts
  • packages/openrouter/endpoints/generations.ts
  • packages/openrouter/endpoints/index.ts
  • packages/openrouter/endpoints/key.ts
  • packages/openrouter/endpoints/messages.ts
  • packages/openrouter/endpoints/model-endpoints.ts
  • packages/openrouter/endpoints/models.ts
  • packages/openrouter/endpoints/providers.ts
  • packages/openrouter/endpoints/types.ts
  • packages/openrouter/endpoints/zdr.ts
  • packages/openrouter/error-handlers.ts
  • packages/openrouter/index.ts
  • packages/openrouter/jest.config.cjs
  • packages/openrouter/package.json
  • packages/openrouter/schema.test.ts
  • packages/openrouter/schema/index.ts
  • packages/openrouter/tsconfig.json
  • packages/openrouter/tsup.config.ts

Comment thread packages/corsair/core/constants.ts Outdated
Comment thread packages/openrouter/api.test.ts
Comment thread packages/openrouter/client.ts
Comment thread packages/openrouter/endpoints/credits.ts Outdated
Comment thread packages/openrouter/endpoints/types.ts
Comment thread packages/openrouter/index.ts
Comment thread packages/openrouter/index.ts
Comment thread packages/openrouter/package.json
Comment thread packages/openrouter/README.md
Comment thread packages/openrouter/README.md Outdated
@ambikeesshh

Copy link
Copy Markdown
Collaborator

@greptileai review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/openrouter/api.test.ts`:
- Around line 886-893: Remove the OPENROUTER_API_KEY-gated live test setup and
its direct makeOpenRouterRequest usage in the “OpenRouter API type tests (live)”
suite. Route model validation through llm.corsair.dev using the existing LiteLLM
OpenAI-compatible gateway client, without provider SDK calls or direct provider
keys.

In `@packages/openrouter/endpoints/types.ts`:
- Line 275: Update the maxTokens schema definition to make the field optional
while requiring integer values of at least 1, matching the max_tokens input
contract. Add coverage for omitted, decimal, and zero maxTokens values.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 46caea7d-2dd2-4e72-96e4-c36656782353

📥 Commits

Reviewing files that changed from the base of the PR and between 6109890 and 515b868.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • packages/corsair/core/constants.ts
  • packages/openrouter/README.md
  • packages/openrouter/api.test.ts
  • packages/openrouter/endpoints/credits.ts
  • packages/openrouter/endpoints/embeddings.ts
  • packages/openrouter/endpoints/index.ts
  • packages/openrouter/endpoints/messages.ts
  • packages/openrouter/endpoints/model-endpoints.ts
  • packages/openrouter/endpoints/models.ts
  • packages/openrouter/endpoints/types.ts
  • packages/openrouter/error-handlers.ts
  • packages/openrouter/index.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/openrouter/endpoints/embeddings.ts
  • packages/openrouter/endpoints/model-endpoints.ts
  • packages/corsair/core/constants.ts
  • packages/openrouter/README.md
  • packages/openrouter/endpoints/models.ts
  • packages/openrouter/endpoints/messages.ts
  • packages/openrouter/endpoints/index.ts
  • packages/openrouter/index.ts

Comment thread packages/openrouter/api.test.ts
Comment thread packages/openrouter/endpoints/types.ts Outdated

@ambikeesshh ambikeesshh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed fixes for the deprecated Coinbase operation, API contracts, tool and thinking flows, retry safety, tests, and docs

@Mayank-saraswal

Copy link
Copy Markdown
Contributor Author

@greptileai

@Mayank-saraswal

Copy link
Copy Markdown
Contributor Author

@greptileai

@ambikeesshh

Copy link
Copy Markdown
Collaborator

@greptileai

@ambikeesshh ambikeesshh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tightened chat maxTokens so 0/floats don’t get through. dropped coinbase from the description too
lgtm now

@ambikeesshh

Copy link
Copy Markdown
Collaborator

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes in packages/corsair docs Docs / Mintlify / markdown changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Integration request]: OpenRouter

2 participants